<?php

namespace app\api\model;

use traits\model\SoftDelete;

class RotationChartImgsModel extends BaseModel
{
    use SoftDelete;

    protected $pk = 'id';
    protected $table = 'hs_rotation_chart_imgs';
    protected static $tableName = 'rotation_chart_imgs';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';


    //状态常量
    const STATUS_OPEN = 1;//开启
    const STATUS_CLOSE = 0;//隐藏

    public function getImageAttr($value)
    {
        if ($value) {
            $host = $_SERVER['HTTP_HOST'];
            return 'https://' . $host . $value;
        }
        return '';
    }

    //获取首页轮播图列表
    public static function lst()
    {
        return self::where('status', self::STATUS_OPEN)->field('id,image,url')->select();
    }
}